﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LIM.controller;
using LIM.model;
using Microsoft.Reporting.WinForms;
namespace LIM.report
{
    public partial class frm_RPBaoGia : Form
    {
        public frm_RPBaoGia()
        {
            InitializeComponent();
        }
        DanhMucBaoGiaController controller = new DanhMucBaoGiaController();
        public int RowIDBaoGIa = 5;
        private void frm_RPBaoGia_Load(object sender, EventArgs e)
        {
            if (RowIDBaoGIa != 0)
            {
                tbl_CRM_BaoGia baogia = controller.LoadBaoGiaByID(RowIDBaoGIa);
                string KhachHang = "";
                if (controller.GetKH(baogia.RowIDKhachHang) != null)
                {
                    KhachHang = controller.GetKH(baogia.RowIDKhachHang);
                }
                string NguoiLienHe = "";
                if (controller.GetLienHe(baogia.RowIDLienHe) != null)
                {
                    NguoiLienHe = controller.GetLienHe(baogia.RowIDLienHe);
                }
                #region Paramater
                ReportParameter[] report = new ReportParameter[]
                {
                    new ReportParameter("SoBaoGia",baogia.MaBaoGia),
                    new ReportParameter("NguoiLienHe",NguoiLienHe),
                    new ReportParameter("KhachHang",KhachHang),
                    new ReportParameter("Email",baogia.Email),
                    new ReportParameter("DT",baogia.SoDiDong),
                    new ReportParameter("Nguoilap",baogia.NguoiTao),
                    new ReportParameter("NgayBaoGia",baogia.NgayTao.HasValue ? baogia.NgayTao.Value.ToString() : ""),
                };
                #endregion
                vBaoGiaChiTieuBindingSource.DataSource = controller.LoadBaoGiaChiTieuByRowIDBaoGia(baogia.RowID);
                reportViewer1.LocalReport.SetParameters(report);
                reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                reportViewer1.ZoomMode = ZoomMode.Percent;
                reportViewer1.ZoomPercent = 100;
                this.reportViewer1.RefreshReport();
            }
            
        }
    }
}
